package com.example.springredistest.tools;

import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
import me.chanjar.weixin.mp.bean.kefu.WxMpKefuMessage;
import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl;
import org.springframework.stereotype.Component;

/**
 * @author tangmingze
 */
@Component
public class GetUserMain {
    private final static String appid = "wxa744a1995ff1aa4b";
    private final static String appsecret = "82e663ca7fa5f24cf67bd690aa278e1f";
    private static final String token = "aabbcc";
    private volatile WxMpDefaultConfigImpl config;
    private volatile    WxMpService wxService;

    public GetUserMain() {
        this.config = new WxMpDefaultConfigImpl();
        config.setAppId(appid); // 设置微信公众号的appid
        config.setSecret(appsecret); // 设置微信公众号的app corpSecret
        config.setToken(token);
        this.wxService = new WxMpServiceImpl();// 实际项目中请注意要保持单例，不要在每次请求时构造实例，具体可以参考demo项目
        wxService.setWxMpConfigStorage(config);;
    }
    public WxMpDefaultConfigImpl getConfig() {
        return config;
    }

    public WxMpService getWxService() {
        return wxService;
    }
}
